﻿Namespace Models

    Public Interface IAlumnos_Grados
        <Authorize(Roles:="ERA")> _
        Function GetGrados_ByAlumno(NIE As String) As List(Of VIEW_ALL_GRADOS_ALUMNOS)
    End Interface

    Partial Public Class SchoolClickDB_Repositorio
        Implements IAlumnos_Grados

        Public ReadOnly Property IAlumnos_Grados() As IAlumnos_Grados
            Get
                Return DirectCast(Me, IAlumnos_Grados)
            End Get
        End Property

        Private Function GetGrados_ByAlumno(NIE As String) As List(Of VIEW_ALL_GRADOS_ALUMNOS) Implements IAlumnos_Grados.GetGrados_ByAlumno
            Try
                Using cnn As New SchoolClickEntities
                    Return cnn.VIEW_ALL_GRADOS_ALUMNOS _
                                    .Where(Function(ag) ag.ID_ALUMNO = NIE) _
                                    .OrderByDescending(Function(ag) ag.ANIO_ESCOLAR) _
                                    .ToList
                End Using
            Catch ex As Exception
                Throw New ApplicationException(String.Format("Ocurrió un error inesperado al intentar recuperar el listado de los grados del alumno con NIE {0}.", NIE), ex)
            End Try
        End Function
    End Class
End Namespace
